import unittest
from api.login import LoginAPI
from common.common_assert import common_assert

#创建测试类
class TestLoginAPI(unittest.TestCase):
    #登陆成功
    def test01_success(self):
        response = LoginAPI().login({"mobile":"13800000002","password":"123456"})
        print(response.json())

        #断言
        # self.assertEqual(200,response.status_code)
        # self.assertEqual(True,response.json().get("success"))
        # self.assertEqual(10000,response.json().get("code"))
        # self.assertIn("成功",response.json().get("message"))
        # self.assertIn("成功",response.text)
        # common_assert(self,response,200,True,10000,"成功")
        common_assert(self,response)

    #账号错误
    def test02_success(self):
        response = LoginAPI().login({"mobile": "13866778899", "password": "123456"})
        print(response.json())

        #断言
        # self.assertEqual(200,response.status_code)
        # self.assertEqual(False,response.json().get("success"))
        # self.assertEqual(20001,response.json().get("code"))
        # self.assertIn("错误",response.json().get("message"))
        # self.assertIn("错误",response.text)
        common_assert(self,response,200,False,20001,"错误")

    #密码错误
    def test03_success(self):
        response = LoginAPI().login({"mobile":"13800000002","password":"1234574"})
        print(response.json())
        # 断言
        # self.assertEqual(200,response.status_code)
        # self.assertEqual(False,response.json().get("success"))
        # self.assertEqual(20001,response.json().get("code"))
        # self.assertIn("错误",response.json().get("message"))
        # self.assertIn("错误",response.text)
        common_assert(self, response, 200, False, 20001, "错误")